<template>
	<el-card class="form-container">
		<el-form :model="dataForm" ref="dataForm" :rules="dataRule" @keyup.enter.native="dataFormSubmitHandle()" label-width="90px">
			<el-form-item label="场次名称" prop="sceneName">
				<el-input v-model="dataForm.sceneName" placeholder="请输入场次名称"></el-input>
			</el-form-item>
			<el-form-item label="开始时间" prop="startTime">
				<el-time-picker
					v-model="dataForm.startTime"
					placeholder="任意时间点">
				</el-time-picker>
			</el-form-item>
			<el-form-item label="结束时间" prop="endTime">
				<el-time-picker
					v-model="dataForm.endTime"
					placeholder="任意时间点">
				</el-time-picker>
			</el-form-item>
			<el-form-item label="时间状态" prop="timeStatus">
				<el-radio-group v-model="dataForm.timeStatus">
					<el-radio label="1">启用</el-radio>
					<el-radio label="2">禁用</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item>
				<el-button @click="cancel('dataForm')">取 消</el-button>
				<el-button type="primary" @click="submitCreate('dataForm')">确 定</el-button>
			</el-form-item>
		</el-form>
	</el-card>
</template>

<script>
	import { addSeckillScene} from '@/api/activity/seckill'
	export default {
		name: 'add-seckill-scene',
		data() {
			return {
				senceList:[],
				dataForm: {
					id:'',
					sceneName: '',
					startTime: '',
					endTime: '',
					timeStatus: '',
				},
				dataRule: {
					seckillName: [{
							required: true,
							message: '请输入秒杀活动名称',
							trigger: 'blur'
						},
					],
					startTime: [{
							required: true,
							message: '请输入秒杀开始时间',
							trigger: 'blur'
						},
					],
					endTime: [{
							required: true,
							message: '请输入秒杀结束时间',
							trigger: 'blur'
						},
					],
				}
			}
		},
		methods: {
			cancel() {
				this.$router.go(-1)
			},
			submitCreate() {
				const set = this.$refs;
				set['dataForm'].validate((valid) => {
					if (!valid) {
						return false
					}
					addSeckillScene(this.dataForm).then(() => {
						this.$notify({
							title: '添加成功',
							message: '添加成功',
							type: 'success',
							duration: 2000,
							onClose: this.$router.go(-1)
						})
					})
				})
			}
		}
	}
</script>

<style>
</style>
